Public Class ReportSchedule_Factory
    Public Function GetReportForSystem() As ReportSchedule
        Dim oFactory As New DBReportSchedule_Factory

        Return oFactory.GetReportForSystem
    End Function

    Public Function GetReportForServer(ByVal lServerID As Long) As ReportSchedule
        Dim oFactory As New DBReportSchedule_Factory

        Return oFactory.GetReportForServer(lServerID)
    End Function

    Public Function GetReportForDatabase(ByVal lDatabaseID As Long) As ReportSchedule
        Dim oFactory As New DBReportSchedule_Factory

        Return oFactory.GetReportForDatabase(lDatabaseID)
    End Function

    Public Sub SetReportValue( _
                    ByVal lServerID As Long, _
                    ByVal lDatabaseID As Long, _
                    ByVal iDelayDays As Integer, _
                    ByVal iHours As Integer, _
                    ByVal iMinutes As Integer, _
                    ByVal bIsPM As Boolean, _
                    ByVal sReportEmail As String)

        Dim oReport As ReportSchedule = Nothing

        If lServerID <> Base.NODATA Then
            oReport = GetReportForServer(lServerID)

        ElseIf lDatabaseID <> Base.NODATA Then
            oReport = GetReportForDatabase(lDatabaseID)

        Else
            oReport = GetReportForSystem()

        End If

        If oReport Is Nothing Then
            oReport = New ReportSchedule
        End If

        oReport.ServerID = lServerID
        oReport.DatabaseID = lDatabaseID
        oReport.DelayDays = iDelayDays
        oReport.SetTimeOfDay(iHours, iMinutes, bIsPM)
        oReport.RecipientEmailAddresses = sReportEmail

        oReport.Save()
    End Sub

    Public Function SendNextScheduledReport() As ReportSchedule
        Dim oFactory As New DBReportSchedule_Factory

        Return oFactory.GetNextScheduledReport
    End Function
End Class
